<template>
  <div class="channel">
    <div @click="itemClick(item)" 
         class="shannel-item" 
         v-for="item in channel" 
         :key="item.id">
      <img :src="item.icon_url" alt="">
      <span>{{item.name}}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    channel: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    itemClick(item) {
      let index = this.channel.findIndex(items => items.id == item.id)
      let id = this.channel[index].id
      console.log(id)
      this.$router.push({
        path: '/categorylist',
        query: {
          id
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.channel {
  display: flex;
  padding: 10px 0;
  background-color: #fff;
  .shannel-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    img {
      width: 29px;
    }
    span {
      margin: 12px 0;
    }
  }
}
</style>